package fakedata

import (
	"doctor_api_backend/config"
	"doctor_api_backend/models"
	"strconv"
	"time"
)

// 生成入院通知单假数据	,生成的通知单不能有code重复
// 每个fake data函数内容要详细
func SeedAdmissionNotice() {
	// 生成100条入院通知单假数据
	for i := 0; i < 100; i++ {

		// 生成随机科室
		department := "内科"
		if i%2 == 0 {
			department = "外科"
		}

		// 生成随机诊断
		diagnosis := "感冒"
		if i%3 == 0 {
			diagnosis = "发烧"
		}

		// 生成随机诊断编码
		diagnosisCode := "ADM" + strconv.Itoa(i)
		if i%4 == 0 {
			diagnosisCode = "ADM" + strconv.Itoa(i)
		}

		// 生成随机入院通知书内容
		admissionNoticeContent := "感冒"
		if i%5 == 0 {
			admissionNoticeContent = "发烧"
		}

		// 生成随机入院通知单编码
		admissionNoticeCode := "ADM" + strconv.Itoa(i)
		if i%6 == 0 {
			admissionNoticeCode = "ADM" + strconv.Itoa(i)
		}

		// 生成随机入院日期
		admissionDate := time.Now().AddDate(0, 0, i)
		if i%7 == 0 {
			admissionDate = time.Now().AddDate(0, 0, i)
		}

		// 生成随机患者ID
		patientID := i
		if i%8 == 0 {
			patientID = i
		}

		// 生成随机医生ID
		doctorID := i
		if i%9 == 0 {
			doctorID = i
		}

		// 生成入院通知单
		admissionNotice := models.AdmissionNotice{

			AdmissionNoticeCode:    admissionNoticeCode,
			PatientID:              patientID,
			DoctorID:               doctorID,
			AdmissionDate:          admissionDate,
			AdmissionDepartment:    department,
			AdmissionDiagnosis:     diagnosis,
			AdmissionDiagnosisCode: diagnosisCode,
			AdmissionNoticeContent: admissionNoticeContent,
		}

		// 保存入院通知单
		config.DB.Create(&admissionNotice)
	}
}
